/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package models;

import cstAndEnum.*;
import java.util.List;
import models.Deck.Deck;

/**
 * 游戏
 * @author Invince
 */
public class Game {
   /*----------Attributs-------------------*/
    /**
     * 玩家列表
     */
    protected ListPlayer listPlayer;
    /**
     * 主公的ID
     */
    protected int majestyID;
    /**
     * 摸牌堆
     */
    protected Deck baseDeck;
    /**
     * 弃牌堆
     */
    protected Deck abandonDeck;
    /**
     * 死亡的玩家
     */
    protected ListPlayer listDiePlayer;


   /*----------Public functions------------*/
    /**
     * 玩家死亡
     * @param player
     * @return
     */
    public boolean playerDie(Player player){
        String s = "Game--playerDie: " + player.getName() + " dies";
        String r = "";
        boolean rb = false;
        if (this.listPlayer.getList().contains(player) ){
            rb=true;
            this.listPlayer.getList().remove(player);
            this.listDiePlayer.addPlayer(player);
        }
        //注意操作ListPlayer，改index??????????????????????????
        if(!rb)
            r="Failed: ";
        r+=s;
        CST.println(r);
        return rb;
    }
    //这里还有很多functions

   /*----------Private functions-----------*/
   /*----------Constructor-----------------*/
    /**
     *
     * @param listPlayer 玩家列表
     * @param baseDeck   摸牌库
     */
    public Game(List<Player> listPlayer,int majestyID, Deck baseDeck) {
        this.listPlayer = new ListPlayer(listPlayer);
        this.majestyID=majestyID;
        this.baseDeck = baseDeck;
        // 一个空的死亡了的玩家列表
        this.listDiePlayer=new ListPlayer();
        // 一个空的弃牌库
        this.abandonDeck = new Deck();
    }

    
    /*----------Gets and sets---------------*/
    public Deck getBaseDeck() {
        return baseDeck;
    }

    public void setBaseDeck(Deck baseDeck) {
        this.baseDeck = baseDeck;
    }

    public ListPlayer getListPlayer() {
        return listPlayer;
    }

    public void setListPlayer(List<Player> listPlayer) {
        this.listPlayer.setList(listPlayer);
    }

    public Deck getAbandonDeck() {
        return abandonDeck;
    }

    public ListPlayer getListDiePlayer() {
        return listDiePlayer;
    }

    public int getMajestyID() {
        return majestyID;
    }
    
}
